package ntrees.hu.pxinput;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.graphics.Canvas;

public class ArcViewGroup extends ArcView {

	List<ArcView> mViewList = new ArrayList<ArcView>();
	public static final int VERTICAL = 0;
	public static final int HORIZONTAL = 1;
	private int orientation = HORIZONTAL;
	public ArcViewGroup(Context context) {
		super(context);
	}
	
	public void addView(ArcView v) {
		mViewList.add(v);
	}

	public void addView(int index, ArcView v) {
		mViewList.add(index, v);
	}
	
	public void setOrientation(int orientation) {
		this.orientation = orientation;
	}
	
	public void onDraw(Canvas canvas) {
		if (orientation == HORIZONTAL) {
			float startAngle = startAngle();
			for (ArcView v : mViewList) {
				v.setAngle(startAngle + v.sweepAngle() / 2);
				v.setRadius(this.radius());
				v.setWidth(width());
				v.setCenter(center().x, center().y);
				v.draw(canvas);
				startAngle += v.sweepAngle();
				v.dump("ArcViewGroup");
			}
		}
		else if (orientation == VERTICAL) {
			float startRadius = radius();//(int) (radius - width / 2f);
			for (ArcView v : mViewList) {
				v.setRadius(startRadius);
				v.setCenter(center().x, center().y);
				v.draw(canvas);
				startRadius += v.width();
				v.dump("ArcViewGroup");
			}
		}
	}
}
